/******************************************************
*  Copyright(c) pages.ilovezxl.top
*  FileName : gpio.c
*  Author : rivulet.dave
*  Description : GPIO模块实现
*  Data : 2019-04-15
******************************************************/

/*********************************************************************
 * INCLUDES
 */

#include "stdrope.h"
#include "util.h"

#include "hallib.h"
#include "halagent.h"

#include "gpio.h"

#if (HAL_PRODUCER == _HAL_LINUX_)
#include "gpio_linux.h"
#elif (HAL_PRODUCER == _HAL_STM32_)
#include "gpio_stm32.h"
#else
#endif  // HAL_PRODUCER == _HAL_LINUX_

#if (HAL_GPIO == _ENABLE)

/*********************************************************************
 *  EXTERNAL VARIABLES
 */

/*********************************************************************
 * MACROS
 */

/*********************************************************************
 * TYPES
 */

typedef struct _hal_gpio_cb
{
    MOD_INFO_S stModInfo;
    HAL_OPER_S *pstGpioBaseOper;
} HAL_GPIO_CB_S;

/*********************************************************************
 * FUNCTIONS DECLARE
 */

/*********************************************************************
 * VARIABLES
 */

static HAL_GPIO_CB_S s_stGpioHandlers = { 0 };

/*********************************************************************
 * FUNCTIONS
 */

/**
 *   @Description: GPIO模块初始化
 *   @param : NA
 *   @return:模块描述符
 */
hd_t GPIO_Init(void)
{
#if (HAL_PRODUCER == _HAL_LINUX_)
    s_stGpioHandlers.stModInfo.uiModID = HW_GPIO * 100 + _HAL_LINUX_;
    s_stGpioHandlers.stModInfo.pName = "HW_LINUX_GPIO";
    s_stGpioHandlers.pstGpioBaseOper = GPIO_LinuxObjNew();
    return (hd_t)(s_stGpioHandlers.pstGpioBaseOper);
#elif (HAL_PRODUCER == _HAL_STM32_)
    s_stGpioHandlers.stModInfo.uiModID = HW_GPIO * 100 + _HAL_STM32_;
    s_stGpioHandlers.stModInfo.pName = "HW_STM32_GPIO";
    s_stGpioHandlers.pstGpioBaseOper = GPIO_STM32ObjNew();
    return (hd_t)(s_stGpioHandlers.pstGpioBaseOper);
#else
    return NULL;
#endif
}

/**
 *   @Description: GPIO模块退出
 *   @param  : NA
 *   @return : NA
 */
void GPIO_Exit(void)
{
#if (HAL_PRODUCER == _HAL_LINUX_)
    GPIO_LinuxObjDelete();
#elif (HAL_PRODUCER == _HAL_STM32_)
    GPIO_STM32ObjDelete();
#else
#endif
    s_stGpioHandlers.pstGpioBaseOper = NULL;
}

#endif  // HAL_GPIO == _ENABLE

/************************************** The End Of File **************************************/

